package com.gjs.freechat.server.component.bean;

import com.gjs.freechat.server.component.ChatSessionManage;

public class Message {
	
	public static int MESSAGE_TYPE_TEXT = 1;
	public static int MESSAGE_TYPE_IMAGE = 2;
	public static int MESSAGE_TYPE_LOGIN_STATUS = 3;
	public static int MESSAGE_TYPE_ONLINE_USER_NUM = 4;
	public static int MESSAGE_TYPE_USER_MATCH = 5;
	public static int MESSAGE_TYPE_REMOVE_CONVO = 6;
	public static int MESSAGE_TYPE_ADD_FRIEND_REQUEST = 7;
	public static int MESSAGE_TYPE_ADD_FRIEND_REQUEST_STATUS = 8;
	
	private String sessionId;
	private int msgId;
	private int msgType;
	private String content;
	private String sendTime;
	private String senderId;
	private String receiverId;
	private int isTimeNode;
	
	
	public Message() {}
	
	public Message(String sessionId, int msgType, String content, String senderId, String recevierId) {
		this.sessionId = sessionId;
		this.senderId = senderId;
		this.receiverId = recevierId;
		this.msgType = msgType;
		this.content = content;
	}
	
	public String getSessionId() {
		return sessionId;
	}
	public void setSessionId(String sessionId) {
		this.sessionId = sessionId;
	}
	public int getMsgId() {
		return msgId;
	}
	public void setMsgId(int msgId) {
		this.msgId = msgId;
	}
	public int getMsgType() {
		return msgType;
	}
	public void setMsgType(int msgType) {
		this.msgType = msgType;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getSendTime() {
		return sendTime == null ? sendTime : sendTime.substring(0, sendTime.lastIndexOf(':'));
	}
	public String getRealSendTime() {
		return sendTime;
	}
	public void setSendTime(String sendTime) {
		this.sendTime = sendTime;
	}
	public String getSenderId() {
		return senderId;
	}
	public void setSenderId(String senderId) {
		this.senderId = senderId;
	}
	public String getReceiverId() {
		return receiverId;
	}
	public void setReceiverId(String receiverId) {
		this.receiverId = receiverId;
	}
	public int getIsTimeNode() {
		return isTimeNode;
	}
	public void setIsTimeNode(int isTimeNode) {
		this.isTimeNode = isTimeNode;
	}
	
	public String getImagePath() {
		if (msgType == MESSAGE_TYPE_IMAGE)
			return ChatSessionManage.IMAGE_REQUEST_LOCATION + content;
		return content;
	}
	
}
